package com.shiqla.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * Desc ${DESC}
 * Auth Shinelon
 * Date 2018/4/24
 */
public class HelloHandler  extends SimpleChannelInboundHandler<String>{


    /**
     * 客户端读取从服务器传过来的数据
     * @param ctx
     * @param msg
     * @throws Exception
     */
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {

        System.out.println("server say: " + msg);
    }

    /**
     * 客户端接入服务器
     * @param ctx
     * @throws Exception
     */
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        super.channelActive(ctx);
        ctx.writeAndFlush("hello world");
    }
}
